home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / lyapunba.zip / LYAP.BAS next >
BASIC Source File  |  1991-09-21  |  2KB  |  72 lines

  1.  
  2. DEFINT I-N: DIM rxy(0 TO 1)
  3. ' set screen defaults
  4. SCREEN 13: CLS
  5.  
  6. ' set parameter ranges:
  7. ' niter = the number of iterations
  8. ' x1, x2 = limits of "b" range
  9. ' y1, y2 = limits of "a" range
  10. ' nx, ny = number of pixels
  11. ' xmax = maximum allowed size of iterate, to avoid overflows
  12.  
  13. x1 = -2: x2 = 4: y1 = -2: y2 = 4
  14. nx = 320: ny = 200: niter = 100: xmax = 10
  15. '  start iteration with x = x0 = critical point
  16. x0 = .5
  17.  
  18. ' determine pixel steps
  19. dx = (x2 - x1) / nx: dy = (y2 - y1) / ny
  20.  
  21. '  start iterating
  22. FOR j = 0 TO ny
  23. ' rxy(0) represents "b" in the "ab" periodic forcing
  24.   rxy(0) = dy * j + y1
  25.   FOR i = 0 TO nx
  26. '   rxy(1) represents "a" in the "ab" forcing
  27.     rxy(1) = dx * i + x1
  28.     x = x0
  29.  
  30. '  iterate niter times to remove transients
  31.     FOR iter = 1 TO niter
  32. '  if l = 1, use "a"; if l = 0, use "b"
  33.     l = iter MOD 2
  34.     x = x * rxy(l) * (1 - x)
  35. '  color divergent points with color #1
  36.     IF ABS(x) > xmax THEN k = 1: GOTO colorpix
  37.     NEXT iter
  38.  
  39. '  iterate niter times to compute exponent, stored in al
  40.     al = 0
  41.     FOR iter = 1 TO niter
  42.       l = iter MOD 2
  43.       x = x * rxy(l) * (1 - x)
  44.       IF ABS(x) > xmax THEN k = 1: GOTO colorpix
  45. '  d = ABS(the derivative of the function, with respect to x)
  46.       d = ABS(rxy(l) * (1 - 2 * x))
  47. '  avoid trying to find LOG(0)
  48.       IF d = 0 THEN d = 1E-10
  49. '  add LOG(d) to the running total for al;
  50. '  since I will scale al to determine a color mapping scheme, I
  51. '  don't need to divide d by LOG(2), as in the SA article
  52.       al = al + LOG(d)
  53. '  only color points with negative exponents (periodic orbits)
  54. '  change this IF-THEN-ELSE block to show positive exponents (chaotic)
  55.     IF al > 0# THEN
  56.       k = 0
  57.     ELSE
  58. '  at this point, use any scale factors you wish to get a nice
  59. '  distribution of colors
  60.       al = al / niter
  61.       k = ((-al * 100#) MOD 255) + 1
  62.     END IF
  63. colorpix: PSET (i, j), k
  64.  
  65.     NEXT i
  66.   NEXT j
  67.  
  68. '  loop until a key is pressed
  69. WHILE INKEY$ = "": WEND
  70. endd: END
  71. <<<>>>
  72.